﻿using System;
using System.Windows.Forms;
using YunNanHealthProject_Register.Utils;

namespace UpLoadDataOnTime.View
{
    public partial class ConfigForm : Form
    {
        public ConfigForm()
        {
            InitializeComponent();
        }

        //将配置保存到ini文件
        private void OKButton_Click(object sender, EventArgs e)
        {
            SaveTempData(Application.StartupPath + "\\TextFile.ini");
            this.Close();
        }

        private void ConfigForm_Load(object sender, EventArgs e)
        {
            LoadTempData(Application.StartupPath + "\\TextFile.ini");
        }

        private void ExitButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        //界面存值
        private void SaveTempData(string path)
        {
            IniHelper.WriteIni("InterfaceConfig", "MZTbPatientInfoCheckBox", MZTbPatientInfoCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "MZTbResistrationCheckBox", MZTbResistrationCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "MZTbClinicRecordCheckBox", MZTbClinicRecordCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "MZTbRecipeCheckBox", MZTbRecipeCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "MZTbMedicineCheckBox", MZTbMedicineCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "MZTbOperationCheckBox", MZTbOperationCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "MZTbCheckRecordCheckBox", MZTbCheckRecordCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "MZTbAssayRecordCheckBox", MZTbAssayRecordCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "MZTbAssayQuotaResultCheckBox", MZTbAssayQuotaResultCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "ZYTbPatientInfoCheckBox", ZYTbPatientInfoCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "ZYTbHospitalizationRecordCheckBox", ZYTbHospitalizationRecordCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "ZYTbDischargeAbstractCheckBox", ZYTbDischargeAbstractCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "ZYTbOperationCheckBox", ZYTbOperationCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "ZYTbCheckRecordCheckBox", ZYTbCheckRecordCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "ZYTbAssayRecordCheckBox", ZYTbAssayRecordCheckBox.Checked.ToString(), path);
            IniHelper.WriteIni("InterfaceConfig", "ZYTbAssayQuotaResCheckBox", ZYTbAssayQuotaResCheckBox.Checked.ToString(), path);
        }

        //界面赋值
        private void LoadTempData(string path)
        {
            try
            {
                MZTbPatientInfoCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "MZTbPatientInfoCheckBox", path).ToLower());
                MZTbResistrationCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "MZTbResistrationCheckBox", path).ToLower());
                MZTbClinicRecordCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "MZTbClinicRecordCheckBox", path).ToLower());
                MZTbRecipeCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "MZTbRecipeCheckBox", path).ToLower());
                MZTbMedicineCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "MZTbMedicineCheckBox", path).ToLower());
                MZTbOperationCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "MZTbOperationCheckBox", path).ToLower());
                MZTbCheckRecordCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "MZTbCheckRecordCheckBox", path).ToLower());
                MZTbAssayRecordCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "MZTbAssayRecordCheckBox", path).ToLower());
                MZTbAssayQuotaResultCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "MZTbAssayQuotaResultCheckBox", path).ToLower());
                ZYTbPatientInfoCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "ZYTbPatientInfoCheckBox", path).ToLower());
                ZYTbHospitalizationRecordCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "ZYTbHospitalizationRecordCheckBox", path).ToLower());
                ZYTbDischargeAbstractCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "ZYTbDischargeAbstractCheckBox", path).ToLower());
                ZYTbOperationCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "ZYTbOperationCheckBox", path).ToLower());
                ZYTbCheckRecordCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "ZYTbCheckRecordCheckBox", path).ToLower());
                ZYTbAssayRecordCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "ZYTbAssayRecordCheckBox", path).ToLower());
                ZYTbAssayQuotaResCheckBox.Checked = bool.Parse(IniHelper.ReadIni("InterfaceConfig", "ZYTbAssayQuotaResCheckBox", path).ToLower());
            }
            catch (Exception e)
            {
                e.ToString();
            }

        }
    }
}
